package com.itheima.kafka.listener;

import com.alibaba.fastjson.JSON;
import com.itheima.kafka.pojo.User;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

import java.util.Optional;

@Component
public class HelloListener {

    @KafkaListener(topics = {"hello-itcast"})
    public void receiverMessage(ConsumerRecord<?,?> record){
        Object value = record.value();
        User user = JSON.parseObject((String) value, User.class);
        System.out.println(user);
    }
}